#pragma once

#include<vector>
namespace Xm
{
	template <class T,class Container = std::vector<T>>
	class priority_queue
	{
		void adjust_up(int child)
		{
			int parent = child / 2 + 1;
			while (parent > 0)
			{
				if (_con[parent] < _con[child])
				{
					::swap(_con[parent], _con[child]);
				}
				else
				{
					break;
				}
				child = parent;
				parent = child / 2 + 1;
			}
		}
		void push(const T& val)
		{
			_con.push_back(val);
			adjust_up(_con.size()-1);
		}

		const T& Top()const
		{
			return _con[0];
		}

		size_t size() const
		{
			return _con.size();
		}

		bool empty()
		{
			return _con.empty();
		}

		void pop()
		{
			::swap(_con[0], _con[_con.size() - 1)];
			_con.pop_back();
			adjust_down();
		}
	private:
		Container _con;
	};
}